package com.virtual.rerijaapps.pet;

import android.app.AlertDialog;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.androidquery.AQuery;
import com.googlecode.androidannotations.annotations.EActivity;
import com.googlecode.androidannotations.annotations.UiThread;
import com.virtual.rerijaapps.pet.ui.DialogProgressButton;

@EActivity()
public class BaseActivity extends FragmentActivity
{
    public AQuery mAquery;
    
    public AlertDialog.Builder mButtonDialog;
    private AlertDialog mAlertDialog;
    private DialogProgressButton mDialogProgressButton;
    
    @Override
    protected void onCreate( Bundle savedInstanceState ) 
    {
        super.onCreate( savedInstanceState );
        mAquery = ( null != mAquery ) ? mAquery : new AQuery( this );
        overridePendingTransition( R.anim.slide_in_left, R.anim.fadeout_short );
    }
    
    @UiThread
    public void completeDialog()
    { 
    	if ( null != mDialogProgressButton )
    	{
    		mDialogProgressButton.setComplete();
    	}
    }
    
    @UiThread
    public void showLoadingDialog( boolean visible )
    {
    	if ( visible )
    	{
    		mButtonDialog = new AlertDialog.Builder( this );
    		mDialogProgressButton = new DialogProgressButton( this );
    		mButtonDialog.setView( mDialogProgressButton );
    		mAlertDialog = mButtonDialog.create();
    		mAlertDialog.setCancelable( false );
    		mAlertDialog.show();
    	}
    	else
    	{
    		mAlertDialog.cancel();
    	}
    }

}
